/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-27 15:32:24
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\CostMonth.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, ExecuteButton } from '../Common/options'
import dayjs from 'dayjs'
import { OrganizationListByPingJi } from '../Common/Conversion'

// isInclude: true,
// NotIdentityLevel: '1,3'
// getOrganizationListByPingJ

export const CostMonth = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: {
            pageIndex: 1,
            isInclude: true,
            NotIdentityLevel: '1,3',
        },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '281c1308-570b-4722-9835-4d44d5e3b719') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'CostMonth' },
            commonTableList.uuid,
            {
                ...commonTableList.organizationUuid,
                valueEnum: await OrganizationListByPingJi('?IsInclude=true&NotIdentityLevel=1,3'),
            },
            {
                dataIndex: 'eventDate',
                title: '申报年月',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
                render: (_, e) => <div>{dayjs(e.eventDate).format('YYYY-MM-DD')}</div>,
            },
            {
                dataIndex: 'createTime',
                title: '填报日期',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            commonTableList.StartTime,
            commonTableList.BeginTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        Permission.findIndex(v => v.uuid === '22ee44b7-0ba8-420c-9c6b-18c5a4ef4002') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),

                        Permission.findIndex(v => v.uuid === '6c8fddf0-4930-4ce1-924a-75ccd632a039') !== -1 && (
                            <OpenExcelButton
                                key="one"
                                title="项目明细"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    CostMonthUuid: uuid,
                                    url: 'getCostMonthCostMonthDetailAcross',
                                    pos: 'posCostMonthCostMonthDetailAcross',
                                }}
                            />
                        ),

                        Permission.findIndex(v => v.uuid === '41095ad0-572e-4d4e-b31d-62ce7373d09d') !== -1 && (
                            <OpenExcelButton
                                key="two"
                                title="公司汇总"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    CostMonthUuid: uuid,
                                    url: 'getCostMonthFilialeCostMonthDetail',
                                    pos: 'posCostMonthFilialeCostMonthDetail',
                                }}
                            />
                        ),

                        Permission.findIndex(v => v.uuid === '67f834b1-25f8-4043-aa8d-08164d0ba445') !== -1 && (
                            <OpenExcelButton
                                key="thr"
                                title="工建汇总"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    // submit: true,
                                    CostMonthUuid: uuid,
                                    url: 'getCostMonthZFilialeCostMonthDetail',
                                    // pos: 'posCostMonthZFilialeCostMonthDetail',
                                }}
                            />
                        ),

                        // Permission.findIndex(v => v.uuid === 'bbf769c3-b210-4800-aede-5e1c350749e8') !== -1 && (
                        //     <OpenExcelButton
                        //         key="fou"
                        //         title="工建明细"
                        //         OptionsEvent={OptionsEvent}
                        //         data={{
                        //             save: true,
                        //             CostMonthUuid: uuid,
                        //             url: 'getCostMonthCompanyCostMonthDetail',
                        //         }}
                        //     />
                        // ),

                        Permission.findIndex(v => v.uuid === '7a413cbe-90a5-4c4d-bedd-41dc3eba3cfc') !== -1 && (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="fiv"
                                title="清除明细数据"
                                url="posCostMonthDelCostMonth"
                                path={[uuid]}
                                tips="明细数据已清除!"
                            />
                        ),

                        Permission.findIndex(v => v.uuid === 'e74afa72-1a13-4519-93d1-e9bf9501bdf3') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
